﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Web.Security;
using UboxUI;//FormsAuthentication
namespace UboxRobot
{
    public partial class Form1 : FrmFather
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void numericUpDown28_ValueChanged(object sender, EventArgs e)
        {
            numericUpDown27.Value = 100 - numericUpDown28.Value;
        }

        private void numericUpDown27_ValueChanged(object sender, EventArgs e)
        {
            numericUpDown28.Value = 100 - numericUpDown27.Value;
        }
        List<string> FEngFirstName = new List<string>();
        List<string> MEngFirstName = new List<string>();
        List<string> EngLastName = new List<string>();
        List<string> ChFirstName = new List<string>();
        List<string> FChLastName = new List<string>();
        List<string> MChLastName = new List<string>();
        private void Form1_Load(object sender, EventArgs e)
        {
            #region
            /*98-------------------------------------------------*/
            EngLastName.Add("Smith");
            EngLastName.Add("Johnson");
            EngLastName.Add("Williams");
            EngLastName.Add("Jones");
            EngLastName.Add("Brown");
            EngLastName.Add("Davis");
            EngLastName.Add("Miller");
            EngLastName.Add("Wilson");
            EngLastName.Add("Moore");
            EngLastName.Add("Taylor");
            EngLastName.Add("Anderson");
            EngLastName.Add("Thomas");
            EngLastName.Add("Jackson");
            EngLastName.Add("White");
            EngLastName.Add("Harris");
            EngLastName.Add("Martin");
            EngLastName.Add("Thomson");
            EngLastName.Add("Carcia");
            EngLastName.Add("Martinez");
            EngLastName.Add("Robinson");
            EngLastName.Add("Clark");
            EngLastName.Add("Rodriguze");
            EngLastName.Add("Lewis");
            EngLastName.Add("Lee");
            EngLastName.Add("Walker");
            EngLastName.Add("Hall");
            EngLastName.Add("Allen");
            EngLastName.Add("Young");
            EngLastName.Add("Hernandez");
            EngLastName.Add("king");
            EngLastName.Add("Wright");
            EngLastName.Add("Lopez");
            EngLastName.Add("Hill");
            EngLastName.Add("Scott");
            EngLastName.Add("Green");
            EngLastName.Add("Adams");
            EngLastName.Add("Baker");
            EngLastName.Add("Gonzalez");
            EngLastName.Add("Nelson");
            EngLastName.Add("Carter");
            EngLastName.Add("Mitchell");
            EngLastName.Add("Perez");
            EngLastName.Add("Roberts");
            EngLastName.Add("Turner");
            EngLastName.Add("Phillips");
            EngLastName.Add("CampBell");
            EngLastName.Add("Parker");
            EngLastName.Add("Evans");
            EngLastName.Add("Edwards");
            EngLastName.Add("Collins");
            EngLastName.Add("Stewart");
            EngLastName.Add("Sanchez");
            EngLastName.Add("Morris");
            EngLastName.Add("Rogers");
            EngLastName.Add("Reed");
            EngLastName.Add("Cook");
            EngLastName.Add("Morgan");
            EngLastName.Add("Bell");
            EngLastName.Add("Murphy");
            EngLastName.Add("Bailey");
            EngLastName.Add("Rivera");
            EngLastName.Add("Cooper");
            EngLastName.Add("Richardson");
            EngLastName.Add("Cox");
            EngLastName.Add("Howard");
            EngLastName.Add("Ward");
            EngLastName.Add("Torres");
            EngLastName.Add("Peterson");
            EngLastName.Add("Gray");
            EngLastName.Add("Ramirez");
            EngLastName.Add("James");
            EngLastName.Add("Watson");
            EngLastName.Add("Brooks");
            EngLastName.Add("Kelly");
            EngLastName.Add("Sanders");
            EngLastName.Add("Price");
            EngLastName.Add("Barnes");
            EngLastName.Add("Ross");
            EngLastName.Add("Henderson");
            EngLastName.Add("Coleman");
            EngLastName.Add("Jenkins");
            EngLastName.Add("Perry");
            EngLastName.Add("Powell");
            EngLastName.Add("Long");
            EngLastName.Add("Patterson");
            EngLastName.Add("Hughes");
            EngLastName.Add("Flores");
            EngLastName.Add("Washington");
            EngLastName.Add("Butler");
            EngLastName.Add("Simmons");
            EngLastName.Add("Foster");
            EngLastName.Add("Gonzales");
            EngLastName.Add("Bryant");
            EngLastName.Add("Alexamder");
            EngLastName.Add("Russell");
            EngLastName.Add("Griffn");
            EngLastName.Add("Diaz");
            EngLastName.Add("Hayes");
            /*105-----------------------------------------------*/
            MEngFirstName.Add("Aaron");
            MEngFirstName.Add("Abel");
            MEngFirstName.Add("Abraham");
            MEngFirstName.Add("Adam");
            MEngFirstName.Add("Adrian");
            MEngFirstName.Add("Aidan");
            MEngFirstName.Add("Alex");
            MEngFirstName.Add("Alva");
            MEngFirstName.Add("Alexander");
            MEngFirstName.Add("Alan");
            MEngFirstName.Add("Albert");
            MEngFirstName.Add("Alfred");
            MEngFirstName.Add("Andrew");
            MEngFirstName.Add("Andy");
            MEngFirstName.Add("Angus");
            MEngFirstName.Add("Anthony");
            MEngFirstName.Add("Apollo");
            MEngFirstName.Add("Arnold");
            MEngFirstName.Add("Arthur");
            MEngFirstName.Add("Augus");
            MEngFirstName.Add("Austin");
            MEngFirstName.Add("Ben");
            MEngFirstName.Add("Benjamin");
            MEngFirstName.Add("Bert");
            MEngFirstName.Add("Benson");
            MEngFirstName.Add("Bill");
            MEngFirstName.Add("Billy");
            MEngFirstName.Add("Blake");
            MEngFirstName.Add("Bob");
            MEngFirstName.Add("Bobby");
            MEngFirstName.Add("Brad");
            MEngFirstName.Add("Brandon");
            MEngFirstName.Add("Brant");
            MEngFirstName.Add("Brent");
            MEngFirstName.Add("Bryan");
            MEngFirstName.Add("Brown");
            MEngFirstName.Add("Bruce");
            MEngFirstName.Add("Caleb");
            MEngFirstName.Add("Cameron");
            MEngFirstName.Add("Carl");
            MEngFirstName.Add("Carlos");
            MEngFirstName.Add("Cary");
            MEngFirstName.Add("Caspar");
            MEngFirstName.Add("Cecil");
            MEngFirstName.Add("Charles");
            MEngFirstName.Add("Cheney");
            MEngFirstName.Add("Chris");
            MEngFirstName.Add("Christian");
            MEngFirstName.Add("Christopher");
            MEngFirstName.Add("Clark");
            MEngFirstName.Add("Cliff");
            MEngFirstName.Add("Cody");
            MEngFirstName.Add("Cole");
            MEngFirstName.Add("Colin");
            MEngFirstName.Add("Cosmo");
            MEngFirstName.Add("Daniel");
            MEngFirstName.Add("Denny");
            MEngFirstName.Add("Darwin");
            MEngFirstName.Add("David");
            MEngFirstName.Add("Dennis");
            MEngFirstName.Add("Derek");
            MEngFirstName.Add("Dick");
            MEngFirstName.Add("Donald");
            MEngFirstName.Add("Douglas");
            MEngFirstName.Add("Duke");
            MEngFirstName.Add("Dylan");
            MEngFirstName.Add("Eddie");
            MEngFirstName.Add("Edgarl");
            MEngFirstName.Add("Edison");
            MEngFirstName.Add("Edmund");
            MEngFirstName.Add("Edward");
            MEngFirstName.Add("Edwin");
            MEngFirstName.Add("Elijah");
            MEngFirstName.Add("Elliott");
            MEngFirstName.Add("Elvis");
            MEngFirstName.Add("Eric");
            MEngFirstName.Add("Ethan");
            MEngFirstName.Add("Eugene");
            MEngFirstName.Add("Evan");
            MEngFirstName.Add("Enterprise");
            MEngFirstName.Add("Ford");
            MEngFirstName.Add("Francis");
            MEngFirstName.Add("Frank");
            MEngFirstName.Add("Franklin");
            MEngFirstName.Add("Fred");
            MEngFirstName.Add("Gabriel");
            MEngFirstName.Add("Gaby");
            MEngFirstName.Add("Garfield");
            MEngFirstName.Add("Gary");
            MEngFirstName.Add("Gavin");
            MEngFirstName.Add("Gino");
            MEngFirstName.Add("Geoffrey");
            MEngFirstName.Add("George");
            MEngFirstName.Add("Glen");
            MEngFirstName.Add("Glendon");
            MEngFirstName.Add("Hank");
            MEngFirstName.Add("Hardy");
            MEngFirstName.Add("Harrison");
            MEngFirstName.Add("Harry");
            MEngFirstName.Add("Hayden");
            MEngFirstName.Add("Henry");
            MEngFirstName.Add("Hilton");
            MEngFirstName.Add("Hugo");
            MEngFirstName.Add("Hunk");
            MEngFirstName.Add("Howard");
            MEngFirstName.Add("Henry");
            /*100---------------------------*/
            FEngFirstName.Add("Abigail");
            FEngFirstName.Add("Abby");
            FEngFirstName.Add("Ada");
            FEngFirstName.Add("Adelaide");
            FEngFirstName.Add("Adeline");
            FEngFirstName.Add("Alexandra");
            FEngFirstName.Add("Ailsa");
            FEngFirstName.Add("Aimee");
            FEngFirstName.Add("Alexis");
            FEngFirstName.Add("Alice");
            FEngFirstName.Add("Alicia");
            FEngFirstName.Add("Alina");
            FEngFirstName.Add("Allison");
            FEngFirstName.Add("Alyssa");
            FEngFirstName.Add("Amanda");
            FEngFirstName.Add("Amy");
            FEngFirstName.Add("Amber");
            FEngFirstName.Add("Anastasia");
            FEngFirstName.Add("Andrea");
            FEngFirstName.Add("Angel");
            FEngFirstName.Add("Angela");
            FEngFirstName.Add("Angelia");
            FEngFirstName.Add("Angelina");
            FEngFirstName.Add("Ann");
            FEngFirstName.Add("Anna");
            FEngFirstName.Add("Anne");
            FEngFirstName.Add("Anita");
            FEngFirstName.Add("Ariel");
            FEngFirstName.Add("Ashley");
            FEngFirstName.Add("Audrey");
            FEngFirstName.Add("Aviva");
            FEngFirstName.Add("Barbara");
            FEngFirstName.Add("Barbie");
            FEngFirstName.Add("Beata");
            FEngFirstName.Add("Beatrice");
            FEngFirstName.Add("Becky");
            FEngFirstName.Add("Bella");
            FEngFirstName.Add("Bess");
            FEngFirstName.Add("Bette");
            FEngFirstName.Add("Betty");
            FEngFirstName.Add("Blanche");
            FEngFirstName.Add("Bonnie");
            FEngFirstName.Add("Brenda");
            FEngFirstName.Add("Brianna");
            FEngFirstName.Add("Britney");
            FEngFirstName.Add("Brittany");
            FEngFirstName.Add("Camille");
            FEngFirstName.Add("Candice");
            FEngFirstName.Add("Candy");
            FEngFirstName.Add("Carina");
            FEngFirstName.Add("Carmen");
            FEngFirstName.Add("Carol");
            FEngFirstName.Add("Caroline");
            FEngFirstName.Add("Carry");
            FEngFirstName.Add("Carrie");
            FEngFirstName.Add("Cassandra");
            FEngFirstName.Add("Cassie");
            FEngFirstName.Add("Catherine");
            FEngFirstName.Add("Cathy");
            FEngFirstName.Add("Chelsea");
            FEngFirstName.Add("Charlene");
            FEngFirstName.Add("Charlotte");
            FEngFirstName.Add("Cherry");
            FEngFirstName.Add("Cheryl");
            FEngFirstName.Add("Chloe");
            FEngFirstName.Add("Chris");
            FEngFirstName.Add("Christina");
            FEngFirstName.Add("Hnnah");
            FEngFirstName.Add("Haley");
            FEngFirstName.Add("Hebe");
            FEngFirstName.Add("Helena");
            FEngFirstName.Add("Hellen");
            FEngFirstName.Add("Henna");
            FEngFirstName.Add("Heidi");
            FEngFirstName.Add("Hillary");
            FEngFirstName.Add("Ingris");
            FEngFirstName.Add("Isabella");
            FEngFirstName.Add("Ishara");
            FEngFirstName.Add("Irene");
            FEngFirstName.Add("Iris");
            FEngFirstName.Add("Ivy");
            FEngFirstName.Add("Kay");
            FEngFirstName.Add("Kate");
            FEngFirstName.Add("Kelly");
            FEngFirstName.Add("Kayla");
            FEngFirstName.Add("Kitty");
            FEngFirstName.Add("Lareina");
            FEngFirstName.Add("Lassie");
            FEngFirstName.Add("Laura");
            FEngFirstName.Add("Lauren");
            FEngFirstName.Add("Lena");
            FEngFirstName.Add("Lydia");
            FEngFirstName.Add("Lillian");
            FEngFirstName.Add("Nikita");
            FEngFirstName.Add("Nina");
            FEngFirstName.Add("Nora");
            FEngFirstName.Add("Norma");
            FEngFirstName.Add("Mavis");
            FEngFirstName.Add("Melody");
            FEngFirstName.Add("Mia");
            FEngFirstName.Add("Mamie");
            /*100---------------------------*/
            ChFirstName.Add("李");
            ChFirstName.Add("王");
            ChFirstName.Add("張");
            ChFirstName.Add("劉");
            ChFirstName.Add("陳");
            ChFirstName.Add("楊");
            ChFirstName.Add("黃");
            ChFirstName.Add("趙");
            ChFirstName.Add("周");
            ChFirstName.Add("吳");
            ChFirstName.Add("徐");
            ChFirstName.Add("孫");
            ChFirstName.Add("朱");
            ChFirstName.Add("馬");
            ChFirstName.Add("胡");
            ChFirstName.Add("郭");
            ChFirstName.Add("林");
            ChFirstName.Add("何");
            ChFirstName.Add("高");
            ChFirstName.Add("梁");
            ChFirstName.Add("鄭");
            ChFirstName.Add("羅");
            ChFirstName.Add("宋");
            ChFirstName.Add("謝");
            ChFirstName.Add("唐");
            ChFirstName.Add("韓");
            ChFirstName.Add("曹");
            ChFirstName.Add("許");
            ChFirstName.Add("鄧");
            ChFirstName.Add("蕭");
            ChFirstName.Add("馮");
            ChFirstName.Add("曾");
            ChFirstName.Add("程");
            ChFirstName.Add("蔡");
            ChFirstName.Add("彭");
            ChFirstName.Add("潘");
            ChFirstName.Add("袁");
            ChFirstName.Add("於");
            ChFirstName.Add("董");
            ChFirstName.Add("餘");
            ChFirstName.Add("蘇");
            ChFirstName.Add("葉");
            ChFirstName.Add("呂");
            ChFirstName.Add("魏");
            ChFirstName.Add("蔣");
            ChFirstName.Add("田");
            ChFirstName.Add("杜");
            ChFirstName.Add("丁");
            ChFirstName.Add("沈");
            ChFirstName.Add("姜");
            ChFirstName.Add("範");
            ChFirstName.Add("江");
            ChFirstName.Add("傅");
            ChFirstName.Add("鐘");
            ChFirstName.Add("盧");
            ChFirstName.Add("汪");
            ChFirstName.Add("戴");
            ChFirstName.Add("崔");
            ChFirstName.Add("任");
            ChFirstName.Add("陸");
            ChFirstName.Add("廖");
            ChFirstName.Add("姚");
            ChFirstName.Add("方");
            ChFirstName.Add("金");
            ChFirstName.Add("邱");
            ChFirstName.Add("夏");
            ChFirstName.Add("譚");
            ChFirstName.Add("韋");
            ChFirstName.Add("賈");
            ChFirstName.Add("鄒");
            ChFirstName.Add("石");
            ChFirstName.Add("熊");
            ChFirstName.Add("孟");
            ChFirstName.Add("秦");
            ChFirstName.Add("閻");
            ChFirstName.Add("薛");
            ChFirstName.Add("侯");
            ChFirstName.Add("雷");
            ChFirstName.Add("白");
            ChFirstName.Add("龍");
            ChFirstName.Add("段");
            ChFirstName.Add("郝");
            ChFirstName.Add("孔");
            ChFirstName.Add("邵");
            ChFirstName.Add("史");
            ChFirstName.Add("毛");
            ChFirstName.Add("常");
            ChFirstName.Add("萬");
            ChFirstName.Add("顧");
            ChFirstName.Add("賴");
            ChFirstName.Add("武");
            ChFirstName.Add("康");
            ChFirstName.Add("賀");
            ChFirstName.Add("嚴");
            ChFirstName.Add("伊");
            ChFirstName.Add("錢");
            ChFirstName.Add("施");
            ChFirstName.Add("牛");
            ChFirstName.Add("洪");
            ChFirstName.Add("游");
            /*70*/
            FChLastName.Add("怡君");
            FChLastName.Add("欣怡");
            FChLastName.Add("雅雯");
            FChLastName.Add("心怡");
            FChLastName.Add("雅婷");
            FChLastName.Add("雅惠");
            FChLastName.Add("雅玲");
            FChLastName.Add("靜怡");
            FChLastName.Add("佩君");
            FChLastName.Add("怡婷");
            FChLastName.Add("淑芬");
            FChLastName.Add("靜宜");
            FChLastName.Add("宜如");
            FChLastName.Add("佳玲");
            FChLastName.Add("慧君");
            FChLastName.Add("怡伶");
            FChLastName.Add("雅芳");
            FChLastName.Add("淑娟");
            FChLastName.Add("淑婷");
            FChLastName.Add("佩珊");
            FChLastName.Add("佳慧");
            FChLastName.Add("佳蓉");
            FChLastName.Add("佳穎");
            FChLastName.Add("淑惠");
            FChLastName.Add("欣儀");
            FChLastName.Add("嘉玲");
            FChLastName.Add("雅慧");
            FChLastName.Add("慧雯");
            FChLastName.Add("玉婷");
            FChLastName.Add("惠如");
            FChLastName.Add("惠君");
            FChLastName.Add("宜芳");
            FChLastName.Add("惠婷");
            FChLastName.Add("淑華");
            FChLastName.Add("雅芬");
            FChLastName.Add("慧玲");
            FChLastName.Add("佩芬");
            FChLastName.Add("雅琪");
            FChLastName.Add("淑萍");
            FChLastName.Add("淑君");
            FChLastName.Add("婉婷");
            FChLastName.Add("佳琪");
            FChLastName.Add("韻如");
            FChLastName.Add("詩婷");
            FChLastName.Add("芳儀");
            FChLastName.Add("宜君");
            FChLastName.Add("佩蓉");
            FChLastName.Add("雅鈴");
            FChLastName.Add("佩玲");
            FChLastName.Add("鈺婷");
            FChLastName.Add("雅萍");
            FChLastName.Add("慧如");
            FChLastName.Add("淑慧");
            FChLastName.Add("靜儀");
            FChLastName.Add("惠玲");
            FChLastName.Add("淑玲");
            FChLastName.Add("美君");
            FChLastName.Add("怡慧");
            FChLastName.Add("千慧");
            FChLastName.Add("馨儀");
            FChLastName.Add("嘉慧");
            FChLastName.Add("美慧");
            FChLastName.Add("美玲");
            FChLastName.Add("曉婷");
            FChLastName.Add("筱婷");
            FChLastName.Add("靜雯");
            FChLastName.Add("雅君");
            FChLastName.Add("怡靜");
            FChLastName.Add("玉玲");
            FChLastName.Add("郁婷");
            /*50*/
            MChLastName.Add("志豪");
            MChLastName.Add("家豪");
            MChLastName.Add("志偉");
            MChLastName.Add("俊宏");
            MChLastName.Add("建宏");
            MChLastName.Add("俊傑");
            MChLastName.Add("家銘");
            MChLastName.Add("宗翰");
            MChLastName.Add("志宏");
            MChLastName.Add("信宏");
            MChLastName.Add("志強");
            MChLastName.Add("智偉");
            MChLastName.Add("明哲");
            MChLastName.Add("志明");
            MChLastName.Add("家榮");
            MChLastName.Add("俊賢");
            MChLastName.Add("俊豪");
            MChLastName.Add("嘉宏");
            MChLastName.Add("建良");
            MChLastName.Add("志銘");
            MChLastName.Add("建文");
            MChLastName.Add("立偉");
            MChLastName.Add("文傑");
            MChLastName.Add("佳宏");
            MChLastName.Add("志遠");
            MChLastName.Add("家瑋");
            MChLastName.Add("建志");
            MChLastName.Add("宗憲");
            MChLastName.Add("彥廷");
            MChLastName.Add("俊男");
            MChLastName.Add("嘉憲");
            MChLastName.Add("彥博");
            MChLastName.Add("俊英");
            MChLastName.Add("嘉明");
            MChLastName.Add("彥文");
            MChLastName.Add("英豪");
            MChLastName.Add("嘉文");
            MChLastName.Add("英傑");
            MChLastName.Add("英明");
            MChLastName.Add("嘉進");
            MChLastName.Add("文章");
            MChLastName.Add("書豪");
            MChLastName.Add("俊霖");
            MChLastName.Add("家舒");
            MChLastName.Add("宇德");
            MChLastName.Add("淯翔");
            MChLastName.Add("昇鍇");
            MChLastName.Add("名軒");
            MChLastName.Add("鴻岳");
            MChLastName.Add("永昌");
            #endregion
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (!timer1.Enabled)
            {
                textBox1.Text = textBox1.Text + "啟動" + Environment.NewLine;
            }
            else 
            {
                textBox1.Text = textBox1.Text + "暫停" + Environment.NewLine;
            }
            timer1.Enabled = !timer1.Enabled;
        }

        private void numericUpDown31_ValueChanged(object sender, EventArgs e)
        {
            timer1.Interval= Convert.ToInt32(this.numericUpDown31.Value * 1000);
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            Random i = new Random(Guid.NewGuid().GetHashCode());
            Decimal malenum = i.Next(0, 9999999);
            Decimal fmalenum = i.Next(0, 9999999);
            Decimal peoplenum = 0;
            #region
            switch (DateTime.Now.Hour)
            {
                case 0:
                    peoplenum = numericUpDown1.Value;
                    break;
                case 1:
                    peoplenum = numericUpDown2.Value;
                    break;
                case 2:
                    peoplenum = numericUpDown3.Value;
                    break;
                case 3:
                    peoplenum = numericUpDown4.Value;
                    break;
                case 4:
                    peoplenum = numericUpDown5.Value;
                    break;
                case 5:
                    peoplenum = numericUpDown6.Value;
                    break;
                case 6:
                    peoplenum = numericUpDown7.Value;
                    break;
                case 7:
                    peoplenum = numericUpDown8.Value;
                    break;
                case 8:
                    peoplenum = numericUpDown9.Value;
                    break;
                case 9:
                    peoplenum = numericUpDown10.Value;
                    break;
                case 10:
                    peoplenum = numericUpDown11.Value;
                    break;
                case 11:
                    peoplenum = numericUpDown12.Value;
                    break;
                case 12:
                    peoplenum = numericUpDown13.Value;
                    break;
                case 13:
                    peoplenum = numericUpDown14.Value;
                    break;
                case 14:
                    peoplenum = numericUpDown15.Value;
                    break;
                case 15:
                    peoplenum = numericUpDown16.Value;
                    break;
                case 16:
                    peoplenum = numericUpDown17.Value;
                    break;
                case 17:
                    peoplenum = numericUpDown18.Value;
                    break;
                case 18:
                    peoplenum = numericUpDown19.Value;
                    break;
                case 19:
                    peoplenum = numericUpDown20.Value;
                    break;
                case 20:
                    peoplenum = numericUpDown21.Value;
                    break;
                case 21:
                    peoplenum = numericUpDown22.Value;
                    break;
                case 22:
                    peoplenum = numericUpDown23.Value;
                    break;
                case 23:
                    peoplenum = numericUpDown24.Value;
                    break;
            }
            #endregion
            peoplenum = peoplenum + numericUpDown25.Value;
            peoplenum = peoplenum + i.Next(0, Convert.ToInt32(numericUpDown26.Value));
            malenum = Convert.ToInt32(peoplenum * (numericUpDown27.Value / 100));
            fmalenum = peoplenum - malenum;
            fmalenum = i.Next(Convert.ToInt32(Convert.ToInt32(fmalenum) * 0.9), Convert.ToInt32(Convert.ToInt32(fmalenum) * 1.1));
            Decimal EngCountrymalenum = i.Next(0, Convert.ToInt32(malenum));
            Decimal ChgCountrymalenum = malenum - EngCountrymalenum;
            Decimal EngCountryfmalenum = i.Next(0, Convert.ToInt32(fmalenum));
            Decimal ChgCountryfmalenum = fmalenum - EngCountryfmalenum;
            DateTime Registrationdate;      
            #region 英文男性
            for (int j = 0; j < EngCountrymalenum; j++)
            {
                if (checkBox1.Checked)
                {
                    Registrationdate = DateTime.Now.AddDays(i.Next(Convert.ToInt32(numericUpDown32.Value) * -1, 0)).AddHours(i.Next(0, 23));
                }
                else
                {
                    Registrationdate = DateTime.Now;
                }
                bool Enable = false;
                string Account = "";
                string Password = "";
                string FirstName = "";
                string LastName = "";
                string Phone = "0" + i.Next(0900000000, 0999999999);
                DateTime birthday = DateTime.Now.AddYears(Convert.ToInt32(numericUpDown29.Value) * -1).AddYears(i.Next((Convert.ToInt32(numericUpDown30.Value) - 10) * -1, 0)).AddDays(i.Next(-365, 0));
                while (!Enable)
                {
                    FirstName = MEngFirstName[i.Next(0, 104)];
                    LastName = EngLastName[i.Next(0, 97)];
                    Account = FirstName + LastName + Convert.ToString(i.Next(0, 99));
                    Password = Account;
                    Enable = AccountCheck(Account);
                }
                AccountAdd(Account, FirstName, LastName, Password, birthday, "M", Phone, Registrationdate);
            }
            #endregion
            #region 中文男性
            for (int j = 0; j < ChgCountrymalenum; j++)
            {
                if (checkBox1.Checked)
                {
                    Registrationdate = DateTime.Now.AddDays(i.Next(Convert.ToInt32(numericUpDown32.Value) * -1, 0)).AddHours(i.Next(0, 23));
                }
                else
                {
                    Registrationdate = DateTime.Now;
                }
                bool Enable = false;
                string Account = "";
                string Password = "";
                string FirstName = "";
                string LastName = "";
                string Phone = "0" + i.Next(0900000000, 0999999999);
                DateTime birthday = DateTime.Now.AddYears(Convert.ToInt32(numericUpDown29.Value) * -1).AddYears(i.Next((Convert.ToInt32(numericUpDown30.Value) - 10) * -1, 0)).AddDays(i.Next(-365, 0));
                while (!Enable)
                {
                    FirstName = ChFirstName[i.Next(0, 99)];
                    LastName = MChLastName[i.Next(0, 49)];
                    Account = MEngFirstName[i.Next(0, 104)] + Convert.ToString(i.Next(0, 99999));
                    Password = Account;
                    Enable = AccountCheck(Account);
                }
                AccountAdd(Account, FirstName, LastName, Password, birthday, "M", Phone, Registrationdate);
            }
            #endregion
            #region 英文女性
            for (int j = 0; j < EngCountryfmalenum; j++)
            {
                if (checkBox1.Checked)
                {
                    Registrationdate = DateTime.Now.AddDays(i.Next(Convert.ToInt32(numericUpDown32.Value) * -1, 0)).AddHours(i.Next(0, 23));
                }
                else
                {
                    Registrationdate = DateTime.Now;
                }
                bool Enable = false;
                string Account = "";
                string Password = "";
                string FirstName = "";
                string LastName = "";
                string Phone = "0" + i.Next(0900000000, 0999999999);
                DateTime birthday = DateTime.Now.AddYears(Convert.ToInt32(numericUpDown29.Value) * -1).AddYears(i.Next((Convert.ToInt32(numericUpDown30.Value) - 10) * -1, 0)).AddDays(i.Next(-365, 0));
                while (!Enable)
                {
                    FirstName = FEngFirstName[i.Next(0, 99)];
                    LastName = EngLastName[i.Next(0, 97)];
                    Account = FirstName + LastName + Convert.ToString(i.Next(0, 99999));
                    Password = Account;
                    Enable = AccountCheck(Account);
                }
                AccountAdd(Account, FirstName, LastName, Password, birthday, "F", Phone, Registrationdate);
            }
            #endregion
            #region 中文女性
            for (int j = 0; j < ChgCountryfmalenum; j++)
            {
                if (checkBox1.Checked)
                {
                    Registrationdate = DateTime.Now.AddDays(i.Next(Convert.ToInt32(numericUpDown32.Value) * -1, 0)).AddHours(i.Next(0, 23));
                }
                else
                {
                    Registrationdate = DateTime.Now;
                }
                bool Enable = false;
                string Account = "";
                string Password = "";
                string FirstName = "";
                string LastName = "";
                string Phone = "0" + i.Next(0900000000, 0999999999);
                DateTime birthday = DateTime.Now.AddYears(Convert.ToInt32(numericUpDown29.Value) * -1).AddYears(i.Next((Convert.ToInt32(numericUpDown30.Value) - 10) * -1, 0)).AddDays(i.Next(-365, 0));
                while (!Enable)
                {
                    FirstName = ChFirstName[i.Next(0, 99)];
                    LastName = FChLastName[i.Next(0, 69)];
                    Account = FEngFirstName[i.Next(0, 99)] + Convert.ToString(i.Next(0, 99999));
                    Password = Account;
                    Enable = AccountCheck(Account);
                }
                AccountAdd(Account, FirstName, LastName, Password, birthday, "F", Phone, Registrationdate);
            }
            #endregion
            textBox1.Text =
                "/*-------------------*/" + Environment.NewLine
                + "共新增" + (malenum + fmalenum) + "人" + Environment.NewLine
                + "英文男性" + EngCountrymalenum + "人\n" + Environment.NewLine
                + "英文女性" + EngCountryfmalenum + "人\n" + Environment.NewLine
                + "中文男性" + ChgCountrymalenum + "人\n" + Environment.NewLine
                + "中文女性" + ChgCountryfmalenum + "人\n" + Environment.NewLine
                +textBox1.Text
                ;
        }
        private bool AccountCheck(string Account)
        {
            string strconn = "Data Source=tcp:t7ujj44f85.database.windows.net,1433;Initial Catalog=UBOX;User ID=ubox_manager@t7ujj44f85;Password=Su3cl3gj94";
            string strcmd = @"if exists
                             (
                              select user_username 
                              from [dbo].[user]
                              where user_username=@Account
                             )
                             begin
                                  set @Result = 0
                             end
                           else
                               begin
                                     set @Result = 1
                               end
                           ";
            using (SqlConnection conn = new SqlConnection(strconn))
            {
                using (SqlCommand cmd = new SqlCommand(strcmd, conn))
                {
                    SqlParameter Result;
                    Result = new SqlParameter("@Result", SqlDbType.Bit);
                    Result.Direction = ParameterDirection.Output;
                            //input
                    cmd.Parameters.AddWithValue("@Account", Account);
                            //output
                            cmd.Parameters.Add(Result);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    return Convert.ToBoolean(cmd.Parameters["@Result"].Value);
                }
            }
        }
        private bool AccountAdd
            (string Account
            , string firstname
            , string lastname
            , string password
            , DateTime birthday
            , string sex
            , string phone
            ,DateTime registrationdate
            ) 
        {
            string strconn = "Data Source=tcp:t7ujj44f85.database.windows.net,1433;Initial Catalog=UBOX;User ID=ubox_manager@t7ujj44f85;Password=Su3cl3gj94";
            #region SQL
            string strcmd = @"Insert Into [dbo].[user]
                           (
                            user_username,
                            user_password,
                            user_password_random,
                            user_first_name,
                            user_last_name,
                            user_birthday,
                            user_sex,
                            user_mobile_phone,
                            user_email,
                            user_visible,
                            user_registration_date
                           ) 
                          Values
                          (
                           @Username,
                           @Password,
                           @Random,
                           @Firstname,
                           @Lastname,
                           @Birthday,
                           @Sex,
                           @Phone,
                           @Email,
                           @Visible,
                           @RegistrationDate
                          )
	                      select @Result =SCOPE_IDENTITY()
                        ";
            #endregion
            using (SqlConnection conn = new SqlConnection(strconn))
            {
                using (SqlCommand cmd = new SqlCommand(strcmd, conn))
                {
                    SqlParameter Result;
                    Result = new SqlParameter("@Result", SqlDbType.Bit);
                    Result.Direction = ParameterDirection.Output;
                    //input
                    Random i = new Random(Guid.NewGuid().GetHashCode());
                    int random = i.Next(0, 999999);
                    string Password = FormsAuthentication.HashPasswordForStoringInConfigFile(password + random.ToString(), "sha1");
                    cmd.Parameters.AddWithValue("@Username", Account);
                    cmd.Parameters.AddWithValue("@Password", Password);
                    cmd.Parameters.AddWithValue("@Random", random);
                    cmd.Parameters.AddWithValue("@Firstname", firstname);
                    cmd.Parameters.AddWithValue("@Lastname", lastname);
                    cmd.Parameters.AddWithValue("@Birthday", birthday);
                    cmd.Parameters.AddWithValue("@Sex", sex);
                    cmd.Parameters.AddWithValue("@Phone", phone);
                    cmd.Parameters.AddWithValue("@Email", password+"@gmail.com");
                    cmd.Parameters.AddWithValue("@Visible", true);
                    cmd.Parameters.AddWithValue("@RegistrationDate", registrationdate);
                    //output
                    cmd.Parameters.Add(Result);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    return Convert.ToBoolean(cmd.Parameters["@Result"].Value);
                }
            }
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {

        }
    }
}
